package xj.meta;

import java.util.List;

public class ReferenceElement extends AbstractModelElement {

  public ReferenceElement() {
  }

  public ReferenceElement(ModelElement ref) {
    setReference(ref);
  }

  public String getRefid() {
    return refid;
  }

  public void setRefid(String refid) {
    this.refid = refid;
    setAttribute(ATTR_REFID, refid);
  }

  public ModelElement getReference() {
    return ref;
  }

  public void setReference(ModelElement ref) {
    this.ref = ref;
    refid = null;
    if (ref != null) {
      refid = ref.getId();
    }
    setAttribute(ATTR_REFID, refid);
  }

  @Override
  public void addOwnedElement(ModelElement e) {
    throw new UnsupportedOperationException(
	"addOwnedElement not supported in ReferenceElement");
  }

  @Override
  public void addOwnedElement(ModelElement e, String role) {
    throw new UnsupportedOperationException(
	"addOwnedElement not supported in ReferenceElement");
  }

  @Override
  public void setOwnedElements(String role, List<ModelElement> l) {
    throw new UnsupportedOperationException(
	"setOwnedElements not supported in ReferenceElement");
  }

  @Override
  public void setOwnedElement(String role, ModelElement e) {
    throw new UnsupportedOperationException(
	"setOwnedElement not supported in ReferenceElement");
  }

  @Override
  public void removeOwnedElement(ModelElement e) {
    throw new UnsupportedOperationException(
	"removeOwnedElement not supported in ReferenceElement");
  }

  @Override
  public void removeOwnedElements(String role) {
    throw new UnsupportedOperationException(
	"removeOwnedElements not supported in ReferenceElement");
  }

  public static final String ATTR_REFID = "refid";

  protected String refid;

  protected ModelElement ref;

}
